/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package UI;

import BO.Controller;
import BO.User;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

/**
 *
 * @author Ymmot
 */
public class EditProfileBean {

    private int id;
    private String firstName;
    private String surName;
    private String address;
    private String zipcode;
    private String city;
    private String country;
    private String oldPassword;
    private String password;
    private String confirmPassword;
    private Controller controller;
    
    /** Creates a new instance of EditProfileBean */
    public EditProfileBean() {
        HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
        User u = (User) session.getAttribute("user");
        id = u.getId();
        firstName = u.getFirstName();
        surName = u.getSurName();
        address = u.getAddress();
        zipcode = u.getZipcode();
        city = u.getCity();
        country = u.getCountry();
        oldPassword = "";
        password = "";
        confirmPassword = "";
        controller = new Controller();
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getSurName() {
        return surName;
    }

    public void setSurName(String surName) {
        this.surName = surName;
    }

    public String getZipcode() {
        return zipcode;
    }

    public void setZipcode(String zipcode) {
        this.zipcode = zipcode;
    }

    public String getConfirmPassword() {
        return confirmPassword;
    }

    public void setConfirmPassword(String confirmPassword) {
        this.confirmPassword = confirmPassword;
    }

    public String getOldPassword() {
        return oldPassword;
    }

    public void setOldPassword(String oldPassword) {
        this.oldPassword = oldPassword;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
    
    public String updateProfile(){
        boolean success = controller.updateProfile(id,firstName,surName,address,zipcode,city,country);
        return "fail";
    }
    
    public String updatePassword(){
        boolean success = controller.updatePassword(id,oldPassword,password,confirmPassword);
        return "fail";
    }
}
